package com.sunday.common.mq.rocket.brave.autoconfiguration;

import com.sunday.common.mq.rocket.brave.RocketTracing;
import com.sunday.common.mq.rocket.brave.aspectj.TracingRocketAspect;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

/**
 * 补全 rocket pull 模式链路问题
 *
 * @author zsy
 * @since 2023/8/16
 */
@Slf4j
@AutoConfiguration(after = RocketMQTemplate.class)
@ConditionalOnBean(RocketTracing.class)
public class RocketTracingAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public TracingRocketAspect tracingRocketAspect() {
        return new TracingRocketAspect();
    }

}
